<div class="span6">
  <h2 class="widget-title"><span><?php echo $category_name; ?></span></h2>
  <div class="sidebar-line"><span></span></div>
  <div class="for-womans flexslider flex-direction-nav-on-top">
    <ul class="slides">
    <?php foreach($products as $key=>$row){ ?>
      <?php if($key%3==0){ ?>
      <li>
      <?php } ?>
        <div class="span4">
          <div class="wdt-product">
            <div class="wdt-products-wrapper">
                <div class="wdt-product active show">
                    <a href="<?php echo $row['href'] ?>" title="<?php echo $row['name'] ?>">
                        <img src="<?php echo $row['thumb'] ?>" alt="<?php echo $row['name'] ?>" />
                    </a>
                    <h4><a href="<?php echo $row['href'] ?>" title="<?php echo $row['name'] ?>"><?php echo $row['name'] ?></a></h4>
                    <ul class="rating">
                        <?php for($i=1;$i<=5;$i++){ ?>
                          <?php if($i<=(int)$row['rating']){ ?>
                          <li><i class="star-on"></i></li>
                          <?php } else{ ?>
                          <li><i class="star-off"></i></li>
                          <?php } ?>
                        <?php } ?>
                    </ul>
                      <div class="wdt-pricing">
                          <a href="<?php echo $row['href'] ?>" title="<?php echo $row['name'] ?>"><span class="amount"><?php echo $row['price'] ?></span></a>
                      </div>
                    <div class="wdt-cart">
                      <div class="wdt-cart-bar">
                        <a href="javascript:;" onclick="addToCart('<?php echo $row['product_id']; ?>');" title="<?php echo $row['name'] ?>"><i class="icon-shopping-cart"></i> Add to basket</a>
                      </div>
                    </div>
                    <div class="wdt-overlay">
                    <a href="<?php echo $row['href'] ?>" title="<?php echo $row['name'] ?>"><span class="amount"><?php echo $row['price'] ?></span></a>
                    </div>
                </div>
            </div>
        </div>
        </div>
        <?php if($key%3==2){ ?>
        </li>
        <?php } ?>
      <?php } ?>
      <?php if(count($products)%3!=0){ ?>
        </li>
      <?php } ?>
    </ul>
  </div>
</div>